package com.vancouver.knows.ui.activity.my;

import android.content.Context;
import android.view.View;

import com.pangu.task.mark.ATaskMark;
import com.pangu.ui.refresh.ARefreshViewController;
import com.pangu.ui.refresh.RefreshControllerView;
import com.vancouver.knows.MainApplication;
import com.vancouver.knows.business.BusinessModule;

/**
 * Created by Chris Li on 2016-07-28.
 */
public class MyUserPostCommentsPullRefreshView extends RefreshControllerView {

    public MyUserPostCommentsPullRefreshView(Context context) {
        super(context);
    }

    @SuppressWarnings("rawtypes")
    @Override
    public void onRefresh(ARefreshViewController controller) {
        ((MyCommentListView) content).handleRefreshLoadItem();
    }

    public void loadData() {
        BusinessModule module = ((MainApplication) imContext).getBusinessModule();
        ATaskMark aTaskMark = module.getTaskMarkPool().getMyUserPostCommentsTaskMark();
        ((MyCommentListView) content).initLoadableView(aTaskMark);
        int count = module.getCacheManager().getMyUserPostCommentCache().getItemInfoCount(aTaskMark);
        if (count > 0 && aTaskMark.getTaskStatus() != ATaskMark.HANDLE_WAIT
                && aTaskMark.getTaskStatus() != ATaskMark.HANDLE_DOING) {
            ((MyCommentListView) content).handleRefreshLoadItem();
        }else {
            if (count==0 && aTaskMark.getTaskStatus() != ATaskMark.HANDLE_DOING) {
                aTaskMark.reinitTaskMark();
            }
        }

    }

    @Override
    protected View createContentView() {
        return new MyCommentListView(getContext(), this);
    }
}
